
function [Z,ZS] = xtoz(x)

for i = 1:5
    for j = 1:13
        Z(i,j) = x((i-1)*13+j);%65,1-65
    end
end
for i = 1:8
    for j = 1:10
        ZS_v(i,j) = x((i-1)*10 + j + 65);%80,66-145
    end 
end
ZS = ZS_v';

% Z: Bioreactor states
% Z = [SI1 SS1 XI1 XS1 XBH1 XBA1 XP1 SO1 SNO1 SNH1 SND1 XND1 SALK1;   % Bioreactor 1
%      SI2 SS2 XI2 XS2 XBH2 XBA2 XP2 SO2 SNO2 SNH2 SND2 XND2 SALK2;   % Bioreactor 2
%      SI3 SS3 XI3 XS3 XBH3 XBA3 XP3 SO3 SNO3 SNH3 SND3 XND3 SALK3;   % Bioreactor 3
%      SI4 SS4 XI4 XS4 XBH4 XBA4 XP4 SO4 SNO4 SNH4 SND4 XND4 SALK4;   % Bioreactor 4
%      SI5 SS5 XI5 XS5 XBH5 XBA5 XP5 SO5 SNO5 SNH5 SND5 XND5 SALK5]   % Bioreactor 5

% ZS: secondary settler state
% ZS = [X_1  SI_1  SS_1  SO_1  SNO_1  SNH_1  SND_1  SALK_1;     % layer 1
%       X_2  SI_2  SS_2  SO_2  SNO_2  SNH_2  SND_2  SALK_2;     % layer 2   
%       X_3  SI_3  SS_3  SO_3  SNO_3  SNH_3  SND_3  SALK_3;     % layer 3
%       X_4  SI_4  SS_4  SO_4  SNO_4  SNH_4  SND_4  SALK_4;     % layer 4
%       X_5  SI_5  SS_5  SO_5  SNO_5  SNH_5  SND_5  SALK_5;     % layer 5   
%       X_6  SI_6  SS_6  SO_6  SNO_6  SNH_6  SND_6  SALK_6;     % layer 6
%       X_7  SI_7  SS_7  SO_7  SNO_7  SNH_7  SND_7  SALK_7;     % layer 7
%       X_8  SI_8  SS_8  SO_8  SNO_8  SNH_8  SND_8  SALK_8;     % layer 8
%       X_9  SI_9  SS_9  SO_9  SNO_9  SNH_9  SND_9  SALK_9;     % layer 9
%       X_10 SI_10 SS_10 SO_10 SNO_10 SNH_10 SND_10 SALK_10]    % layer 10

